﻿using Magellan.Abstractions;
using Magellan.Framework;
using Magellan.Routing;
using Moq;
using NUnit.Framework;

namespace Magellan.Tests
{
    [TestFixture]
    public class NavigatorExtensionsTests
    {
        #region SUT

        public class PatientController : Controller
        {
            public ActionResult Search(string text)
            {
                return Back();
            }
        }

        #endregion

        [Test]
        public void CanNavigateUsingControllerLambda()
        {
            var navigator = new Mock<INavigator>();
            navigator.Setup(x => x.Navigate(It.IsAny<RouteValueDictionary>()))
                .Callback(delegate(RouteValueDictionary routeValues)
                {
                    Assert.AreEqual(3, routeValues.Count);
                    Assert.AreEqual("Hello", routeValues["text"]);
                    Assert.AreEqual("Patient", routeValues["controller"]);
                    Assert.AreEqual("Search", routeValues["action"]);
                });

            navigator.Object.Navigate<PatientController>(x => x.Search("Hello"));

            navigator.Verify(x => x.Navigate(It.IsAny<RouteValueDictionary>()));
        }
    }
}
